*This dofile analyzes the household-level survey data from the IFPRI-EEPRI 2008–2009 dataset. It produces Tables 1, 4, 6 (cols. 1-8), and the household-level summary stats/ regressions in Tables S4, S8, S9, S10, and S11. It also outputs the coefficients used to create Figure 6 (in an R program).

*+++++++++++++ THE BEGINNING +++++++++++++++++++++++++++++++++++++++

clear
set more off

use ".\Data_Tables_1_4_6_S4_S8_S9_S10_S11_Figure_6_Coeffs.dta", clear


*_________________________________________________________________________________
******************************* REGRESSIONS **************************************
*---------------------------------------------------------------------------------

*** Set controls macro

#delimit;

local hh_controls 
hh_cntrl_HH_head_man 
hh_cntrl_HH_head_read_write 
dmedsecorhigher 
hh_cntrl_age_hh_head 
hh_cntrl_age_hh_head_squared
hh_cntrl_qty_HH_members 
hh_cntrl_land_own  
dmownhouse 
dmmorethan1room
dmlargelivestock
yourethshare;

#delimit cr

*** Locals for different sets of RHS variables

local M4b_lin 	 "D 	  	A1 A2 A3 	 A1_B  	A2_B  	A3_B 		   	 A1_S A2_S A3_S 		 A1_B_S    A2_B_S 	 A3_B_S    		        "
local M4c_lin	 "Dfal			 	 A4					 		A4_B 			 		A4_Sfal			 				 	    A4_B_Sfal   "
local M4d_lin 	 "D 	  	A2 A3 	 A2_B  	A3_B 		   	 A2_S A3_S 		 A2_B_S 	 A3_B_S    		        "

local M4b_squ 	 "																		  		 A1_Bsqu_S A2_Bsqu_S A3_Bsqu_S 	 	   	    "
local M4c_squ	 "																		  					  			        A4_Bsqu_Sfal"
local M4d_squ 	 "																		  		 A2_Bsqu_S A3_Bsqu_S 	 	   	    "

local M_b_squ 	 "					   	A1_Bsqu A2_Bsqu A3_Bsqu		   "
local M_c_squ	 "											   	A4_Bsqu"
local M_d_squ 	 "					   	A2_Bsqu A3_Bsqu		   "

local Dell_quad			"D 	  	A1 A2 A3 	latitude longitude lat2 long2 latlong"


**** Initialize all outreg files

local labb: var label mod_input_fertilizer
#delimit;
reg four_modern `M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  , nocon cluster(kebele); 
outreg2 using ".\Table_4.xls"	   ,  bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
outreg2 using ".\Table_6_columns_1to8.xls"	   ,  bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
outreg2 using ".\Table_S9_HH_Level_Results.xls"	   ,  bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
outreg2 using ".\Table_S10_HH_Level_Results.xls"	   ,  bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
			  
reg four_modern `M4c_lin'    `M_c_squ' 	`M4c_squ', nocon cluster(kebele); outreg2 using ".\Table_S8_HH_Level_Results.xls"	   ,  bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4c_lin'    `M_c_squ' 	`M4c_squ') replace;
reg four_modern `M4d_lin'    `M_d_squ' 	`M4d_squ', nocon cluster(kebele); outreg2 using ".\Table_S11_HH_Level_Results.xls"	   ,  bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4d_lin'    `M_d_squ' 	`M4d_squ') replace;

#delimit cr

tempfile four_pairs
   save `four_pairs'


*~~~~~~~~~ Full sample

use `four_pairs', clear
drop if A4==1


*TABLE 1 (ALLOCATION OF MAIN SAMPLE HOUSEHOLD BY DISTANCE TO A REGIONAL BORDER WITH OPPOSITE DECENTRALIZATION STATUS)

gen distance_pos=abs(S)
replace distance_pos=10 if distance_pos<=10
replace distance_pos=15 if distance_pos>10 & distance_pos<=15
replace distance_pos=20 if distance_pos>15 & distance_pos<=20
replace distance_pos=25 if distance_pos>20 & distance_pos<=25
replace distance_pos=50 if distance_pos>25 & distance_pos<=50
replace distance_pos=75 if distance_pos>50 & distance_pos<=75
tab distance_pos D


*TABLE 4 (USE OF MODERN AGRICULTURAL INPUTS)

#delimit;
foreach outcome of varlist four_modern number_modern mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed { ; 
foreach z in "" "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_4.xls", bdec(4) e(all) se label(insert) ctitle(Table 4, `outcome') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; 
}; };

*TABLE 6, COLUMNS 1-8 (USE OF IMPROVED DRINKING WATER SOURCE);

foreach outcome of varlist hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry   { ;
local labb: var label `outcome'; foreach z in "" "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_6_columns_1to8.xls", bdec(4) e(all) se label(insert) ctitle(Table 6 col 1-8, `outcome') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

*TABLE S10 (ROBUSTNESS TO DELL (2010) REGRESSION SPECIFICATION USING QUADRATIC IN LONGITUDE AND LATITUDE;
		  
foreach outcome of varlist  four_modern number_modern { ; 
foreach z in "`hh_controls'" {; 
qui reg `outcome' `Dell_quad' `z', nocon cluster(kebele); outreg2 using ".\Table_S10_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S10, `outcome') 
		  sortvar(`Dell_quad' ) append; 
}; };

foreach outcome of varlist mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry   { ;
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `Dell_quad' `z', nocon cluster(kebele); outreg2 using ".\Table_S10_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S10, `outcome') 
		  sortvar(`Dell_quad' ) append;  }; };		  
#delimit cr


*FIGURE 6 (PRODUCE DATASET FOR USE IN R -- THE PROGRAM USED TO CREATE THE HH-LEVEL OUTCOMES PREDICTION FIGURE)

foreach x in hh53_tim_get_wat_wet hh54_tim_get_wat_dry {
gen `x'60=`x'/60
replace `x'60=. if `x'==.
label var `x'60 "Time to get to water divided by 60 (i.e. in hours rather than min.)"
}

set more off
local hhlevoutcomes = "four_modern number_modern mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet60 hh54_tim_get_wat_dry60"
mat results = J(10,3,0)
local a=1
foreach var of varlist `hhlevoutcomes' {
	label variable `var' "`var'"
	eststo: quietly reg `var' `M4b_lin' `M_b_squ' `M4b_squ' `hh_controls', nocon cluster(kebele)
	mat results[`a',1] = _b[D]
	mat results[`a',2] = _se[D]
	mat results[`a',3] = `a'
	local ++a
	}
esttab using Figure_6_Coefficients.csv, b(4) se(3) starlevels(* 0.1 ** .05 *** .01) replace
mat2txt, matrix(results) saving(Figure_6_Coefficients) replace 
eststo clear


*TABLE S9 (HH-LEVEL OUTCOMES FOR REGRESSIONS CHECKING ROBUSTNESS OF RESULTS TO USE OF NARROWER BANDWIDTHS)

*~~~~~~~~~ Within distance of 50km to the border

use `four_pairs', clear
drop if A4==1
drop if S>=50 | S<=-50

#delimit;
foreach outcome of varlist  four_modern number_modern { ; 
foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S9_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S9 within 50km, `outcome') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; 
}; };

foreach outcome of varlist mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry   { ;
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S9_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S9 within 50km, `outcome') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

#delimit cr

*~~~~~~~~~ Within distance of 25km to the border

use `four_pairs', clear
drop if A4==1
drop if S>=25 | S<=-25

#delimit;
foreach outcome of varlist  four_modern number_modern { ; 
foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S9_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S9 within 25km, `outcome') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; 
}; };

foreach outcome of varlist mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry   { ;
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S9_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S9 within 25km, `outcome') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

#delimit cr


*TABLE S8 (HH-LEVEL OUTCOMES FOR ROBUSTNESS CHECK SHOWING LACK OF SIGNIFICANT IMPACTS OF DECENTRALIZATION AT A REGIONAL BORDER WITH NO POLICY CHANGE)

use `four_pairs', clear
keep if A4==1

#delimit;
foreach outcome of varlist  four_modern number_modern  { ; 
foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4c_lin' `M_c_squ' `M4c_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S8_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S8, `outcome') 
		  sortvar(`M4c_lin' `M_c_squ' `M4c_squ' ) append; 
}; };
#delimit cr


#delimit;
foreach outcome of varlist mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry  { ;
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4c_lin' `M_c_squ' `M4c_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S8_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S8, `outcome') 
		  sortvar(`M4c_lin' `M_c_squ' `M4c_squ' ) append;  }; };
#delimit cr


*TABLE S11 (INDIVIDUAL-LEVEL OUTCOMES FOR ROBUSTNESS CHECK SHOWING RESULTS USING ONLY THE TWO BORDER SEGMENTS FOR WHICH BOTH WERE IN THE SAME PROVINCE DURING 1942--1995)

use `four_pairs', clear
keep if A2==1|A3==1

#delimit;
foreach outcome of varlist  four_modern number_modern  { ; 
foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4d_lin' `M_d_squ' `M4d_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S11_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S11, `outcome') 
		  sortvar(`M4d_lin' `M_d_squ' `M4d_squ' ) append; 
}; };
#delimit cr


#delimit;
foreach outcome of varlist mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry   { ;
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4d_lin' `M_d_squ' `M4d_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S11_HH_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S11, `outcome') 
		  sortvar(`M4d_lin' `M_d_squ' `M4d_squ' ) append;  }; };
#delimit cr


*TABLE S4 (HH-LEVEL DESCRIPTIVE STATISTICS)

use `four_pairs', clear

drop if A4==1

estpost summarize four_modern number_modern mod_input_fertilizer mod_input_insecticide mod_input_herbicide mod_input_improvedseed hh_8new hh_10new hh53_tim_get_wat_wet hh54_tim_get_wat_dry D  hh_cntrl_HH_head_man hh_cntrl_HH_head_read_write dmedsecorhigher hh_cntrl_age_hh_head hh_cntrl_qty_HH_members hh_cntrl_land_own dmownhouse dmmorethan1room dmlargelivestock yourethshare
estout using ".\Table_S4_HH_Level_Sum_Stats.xls", replace cells("mean sd count") label


*+++++ THE END ++++++++++++++++++++++++++++++++++
